#config
import json
from log import log
#取各种配置
class Singleton(type):
    _instances = {}

    def __call__(cls, *args, **kwargs):
        if cls not in cls._instances:
            cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
        return cls._instances[cls]


class MyConfig(metaclass=Singleton):
    def __init__(self):
        try:
            cof = open("config.json")
            cofStr = cof.read()
            self.config = json.loads(cofStr)
        except IOError:
            log.error("err config read fail")
        else:
            log.info("config init success")
            cof.close()
    def get(self):
        return self.config

config = MyConfig().get()

